package com.sp.scmdb.webservice.serviceImpl;

import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.common.util.StringUtils;
import org.springframework.stereotype.Service;

import com.sp.scmdb.bean.UploadDutyBean;
import com.sp.scmdb.dao.DutyDao;
import com.sp.scmdb.dao.DutyLevelDao;
import com.sp.scmdb.entity.Duty;
import com.sp.scmdb.entity.DutyLevel;
import com.sp.scmdb.webservice.model.DutyModel;
import com.sp.scmdb.webservice.service.UploadDutyService;

/**
 * 职务列表上传
 * @author maweiyue
 *
 */
@Service("uploadDutyService")
public class UploadDutyServiceImpl implements UploadDutyService {

	private DutyDao dutyDao;
	private DutyLevelDao dutyLevelDao;
	private static Log log = LogFactory.getLog(UploadDutyServiceImpl.class);
	
	/**
	 * 查询职务列表
	 */
	public List<Duty> queryAll(UploadDutyBean bean){
		List<Duty> listDuty = null;
		try {
			if ("0".equals(bean.getDutyLevel()) || StringUtils.isEmpty(bean.getDutyLevel())) {
				listDuty = dutyDao.queryAll();
			} else {
				listDuty = dutyDao.queryHql("from Duty where dutyLevelId = '" + bean.getDutyLevel() + "'");
			}
		} catch (Exception e) {
			log.error("queryAll fail!reason:" + e.getMessage());
		}
		return listDuty;
	}
	
	/**
	 * 查询职务级别列表
	 */
	public List<DutyLevel> queryDutyLevelList(){
		try {
			return dutyLevelDao.queryAll();
		} catch (Exception e) {
			log.error("queryDutyLevelList fail!reason:" + e.getMessage());
		}
		return null;
	}
	
	/**
	 * 职务信息上传
	 */
	public String uploadDuty(UploadDutyBean bean){
		
		
		return "";
	}
	
	public void setUploadDutyDao(DutyDao dutyDao) {
		this.dutyDao = dutyDao;
	}
	public void setDutyLevelDao(DutyLevelDao dutyLevelDao) {
		this.dutyLevelDao = dutyLevelDao;
	}

}
